package com.tydic.ribbonconsumer.controller;

import com.tydic.ribbonconsumer.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Description: 消费者
 * @Author: xuwenguang
 * @CreateDate: 2019/3/6 10:16
 * @UpdateUser: xuwenguang
 * @UpdateDate: 2019/3/6 10:16
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@RestController
public class ConsumerController {
    @Autowired
    private RestTemplate restTemplate;
    @Resource
    private HelloService helloService;
    @RequestMapping(value="/consumer",method = {RequestMethod.GET})
    public String  hello(){
        return restTemplate.getForEntity("http://serviceprovider/hello",String.class).getBody();
    }

    @RequestMapping(value="/consumer2",method = {RequestMethod.GET})
    public String  hystrix(){
        return helloService.hello();
    }
    @RequestMapping(value="/",method = {RequestMethod.GET})
    public String  heathCheck(){
        return "hello";
    }
}
